package com.hubujun.driverlicense.view;

import android.content.Context;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.widget.TextView;

import com.hubujun.driverlicense.ApplicationContext;


public class IconFontTextView extends TextView {
    private static Typeface mIconfont = Typeface.createFromAsset(ApplicationContext.getContext().getAssets(), "iconfont/iconfont.ttf");

    public IconFontTextView(Context context) {
        this(context, null);
    }

    public IconFontTextView(Context context, AttributeSet attrs) {
        super(context, attrs);

        this.setTypeface(mIconfont);
    }

    @Override
    public void setPressed(boolean pressed) {
        super.setPressed(pressed);
        if(!isEnabled()){
            return ;
        }

        if (pressed) {
            setAlpha(0.5F);
        } else {
            setAlpha(1);
        }
    }

    @Override
    public void setEnabled(boolean enabled) {
        super.setEnabled(enabled);
        if (enabled) {
            setAlpha(1);
        } else {
            setAlpha(0.2F);
        }
    }
}
